package day7;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TestHashSet {
    public static void main(String[] args) {
        Set<String> set = new HashSet();
        set.add("陈毓坚");
        set.add("钟元");
        set.add("何鑫宇");
        set.add("重地");//存储在同一个数组下标
        set.add("通话");//存储在同一个数组下标  存储在重地下面的节点
        set.remove("何鑫宇");
        System.out.println("遍历set集合(增强for)");
        for (String s:set){
            System.out.println(s);
        }
        System.out.println("遍历set集合(迭代器)");
        Iterator<String> iterable = set.iterator();
        while (iterable.hasNext()){
            System.out.println(iterable.next());
        }
    }
}
